function zeroFilledSubarray(nums) {
  let count = 0; // 最终结果
  let currentZeros = 0; // 当前连续0的长度

  for (const num of nums) {
    if (num === 0) {
      currentZeros++;
    } else {
      // 计算当前连续0片段的子数组数目并累加
      count += (currentZeros * (currentZeros + 1)) / 2;
      currentZeros = 0; // 重置计数器
    }
  }

  // 处理数组末尾的连续0片段
  count += (currentZeros * (currentZeros + 1)) / 2;

  return count;
}

// 测试示例
console.log(zeroFilledSubarray([1, 3, 0, 0, 2, 0, 0, 4])); // 输出: 6
console.log(zeroFilledSubarray([0, 0, 0, 2, 0, 0])); // 输出: 9
console.log(zeroFilledSubarray([2, 10, 2019])); // 输出: 0
